<?php
function ganti_photo($id){
	$karyawan = my_get_data_by_id( 'karyawan' , 'karyawan_id' , $id );
	$infokaryawan = loaddata_karyawan($id);
	$photodata =  my_get_data_by_id('photo','biodata_id',$karyawan['biodata_id']); 
	$photod = (file_exists($photodata['upload_path'])) ?'<img src="'.$photodata['upload_path'].'" height="120"   border="0"/>' :'<img src="files/upload/sample_thumb.jpg" height="120"   />' ;
	$delete = (file_exists($photodata['upload_path'])) ? '<br/><a style="font:10px verdana" href="index.php?com=karyawan&task=delete_photo&id='.$id.'">[Delete]</a>' :''; 	
	$view = form_header( "s" , "cp"  );
	$photo = array(
			'name'=>'photo',
			'id'=>'photo',
			'type'=>'file',
			'size'=>'45' 
		);
		$form_field_photo = form_dynamic($photo);
	$view .= form_field_display(   '', '<center>'.$photod .$delete . '</center>'   );
	$view .= form_field_display( $infokaryawan['nama_gelar'].' ('.$infokaryawan['nik'].')'   , "Nama (NIK)"    );
	$view .= form_field_display( $form_field_photo   , "Browse photo"    );
	$submit = array(
		'value' =>  '  Ganti  ' ,
		'name' => 'simpan', 
		'type'=>'submit','class'=>'main_button'
	);
	$form_submit= form_dynamic($submit); 
	
	$view .= form_field_display( $form_submit  , "&nbsp;" ,  "" );
	$view .= form_footer( );
	return $view;
	
}

function karyawan_resign($id){
	$query = "SELECT * FROM pemberhentian WHERE karyawan_id = {$id}";
	$res = my_query($query);
	if(my_num_rows($res) > 0 ){
		return true;
	}
	return false;
}
 
function report_karyawan(){
	$oopps = get_opsi_seting('karyawan_only');	
	my_set_code_js('
		function confirmDelete(i){
		var check = confirm(\'Akan mendelete data? \'); 
		if(check){
			location.href=\'index.php?com=karyawan&task=delete&id=\'+i;
		}
		return;	}
	');

	$header = array(
		'#'=>array('style'=>'border-bottom:2px solid;width:5%'), 
		'pic'=>array('style'=>'border-bottom:2px solid;width:5%'),
		'nik'=>array('style'=>'text-align:center;border-bottom:2px solid;width:10%'),   
		'nama'=>array('style'=>'border-bottom:2px solid;width:20%'),  
		//'usia'=>array('style'=>'text-align:center;border-bottom:2px solid;width:10%'), 
		'jabatan'=>array('style'=>'border-bottom:2px solid;width:25%'), 
		'direktorat'=>array('style'=>'border-bottom:2px solid;width:15%'), 
		' '=>array('style'=>'border-bottom:2px solid;width:15%'), 
	);
	if($oopps == '1'){
		if(isset($_GET['key'])){
		$query = "
			SELECT * FROM karyawan a 
			INNER JOIN biodata b ON a.biodata_id = b.biodata_id
			WHERE karyawan_id NOT IN (select karyawan_id FROM karyawan_disable) 
			AND karyawan_id NOT IN ( SELECT karyawan_id FROM pemberhentian  )
			AND ( b.nama LIKE '%{$_GET['key']}%' OR a.nik ='{$_GET['key']}' )
			ORDER BY a.nik
		";
		}else{
		$query = "
			SELECT * FROM karyawan a 
			INNER JOIN biodata b ON a.biodata_id = b.biodata_id
			WHERE karyawan_id NOT IN (select karyawan_id FROM karyawan_disable)
			AND karyawan_id NOT IN ( SELECT karyawan_id FROM pemberhentian  )
			ORDER BY a.nik		
		";
		}
	
	}else{
		if(isset($_GET['key'])){
		$query = "
			SELECT * FROM karyawan a 
			INNER JOIN biodata b ON a.biodata_id = b.biodata_id
			WHERE karyawan_id NOT IN (select karyawan_id FROM karyawan_disable) 
			AND ( b.nama LIKE '%{$_GET['key']}%' OR a.nik ='{$_GET['key']}' )
			ORDER BY a.nik
		";
		}else{
		$query = "
			SELECT * FROM karyawan a 
			INNER JOIN biodata b ON a.biodata_id = b.biodata_id
			WHERE karyawan_id NOT IN (select karyawan_id FROM karyawan_disable)
			ORDER BY a.nik		
		";
		}
	}if(isset($_GET['th']))echo $query;	
	$result = my_query($query );
	$total_records = my_num_rows($result );
	$scroll_page =5;  
	$per_page =15;  
	$current_page = isset($_GET['page']) ? (int) $_GET['page'] : 1 ; 
	if($current_page < 1){
		$current_page = 1;
	}		 
	$pager_url  ="index.php?com=karyawan&task={$_GET['task']}&field={$_GET['field']}&key={$_GET['key']}&page=";	 
	$inactive_page_tag = 'style="padding:4px;background-color:#BBBBBB"';  
	$previous_page_text = ' Mundur '; 
	$next_page_text = ' Maju ';  
	$first_page_text = ' Awal '; 
	$last_page_text = ' Akhir ';
	
	$kgPagerOBJ = new kgPager();
	$kgPagerOBJ->pager_set(
		$pager_url, 
		$total_records, 
		$scroll_page, 
		$per_page, 
		$current_page, 
		$inactive_page_tag, 
		$previous_page_text, 
		$next_page_text, 
		$first_page_text, 
		$last_page_text ,$pager_url_last); 
	 		
	$result = my_query($query ." LIMIT ".$kgPagerOBJ->start.", ".$kgPagerOBJ->per_page); 	
	$row = array(); 
	$i = ($current_page  - 1 ) * 15; 
	while($ey = my_fetch_array($result )){
		$i++;
		
		/* EDIT */
		$editproperty_admin = array(
						'href'=>'index.php?com=karyawan&task=edit&id='.$ey['karyawan_id'], 
						'title'=>'Edit'
				);
		$edit_button_admin = button_icon( 'b_edit.png' , $editproperty_admin  );
		$editproperty_standar = array(
						'href'=>'javascript:;',
						'onclick'=>'alert(\'Akses di tolak\')',
						'title'=>'Edit'
				);
		$edit_button_standar = button_icon( 'b_edit.png' , $editproperty_standar  );
		$edit_button = admin_link( $edit_button_admin , $edit_button_standar );
		/* END EDIT*/
		/* EDIT */
		$editprofil_admin = array(
						'href'=>'index.php?com=profil_kepegawaian&task=edit&id='.$ey['karyawan_id'], 
						'title'=>'Edit profil kepegawaian'
				);
		$editprofil_button_admin = button_icon( 'b_usredit.png' , $editprofil_admin  );
		$editprofil_standar = array(
						'href'=>'javascript:;',
						'onclick'=>'alert(\'Akses di tolak\')',
						'title'=>'Edit profil kepegawaian'
				);
		$editprofil_button_standar = button_icon( 'b_usredit.png' , $editprofil_standar  );
		$editprofil_button = admin_link( $editprofil_button_admin , $editprofil_button_standar );
		/* END EDIT*/
		
		/* DELETE */
		$deleteproperty_admin = array(
						'href'=>'javascript:; ',
						'onclick'=>'javascript:confirmDelete('.$ey['karyawan_id'].');',
						'title'=>'Delete'
				);
		$delete_button_admin= button_icon( 'cut_on.gif' , $deleteproperty_admin  );
		$deleteproperty_standar = array(
						'href'=>'javascript:; ',
						'onclick'=>'javascript:alert(\'Akses ditolak\')',
						'title'=>'Delete'
				);
		$delete_button_standar= button_icon( 'cut_on.gif' , $deleteproperty_standar  );
		$delete_button = admin_link( $delete_button_admin , $delete_button_standar );
		/* END DELETE */
		
		
		$detailproperty = array(
						'href'=>'index.php?com=karyawan&task=detail&page='.$current_page.'&id='.$ey['karyawan_id'],
						'title'=>'Detail'
				);
		$detail_button = button_icon( 'b_props.png' , $detailproperty  );
		
		$skoringproperty = array(
						'href'=>'index.php?com=karyawan&task=skoring&id='.$ey['karyawan_id'],
						'rel'=>'facebox',
						'title'=>'Hasil seleksi'
				);
		$skoring_button = button_icon( 'paste_on.gif' , $skoringproperty  );
		
		$kekaryawanan = my_query("
		SELECT * FROM jabatan a 
		INNER JOIN kekaryawanan c ON a.jabatan_id=c.jabatan_id
		WHERE c.karyawan_id ={$ey['karyawan_id']} 
		LIMIT 1
		");
		$jbt_karya = my_fetch_array($kekaryawanan );
		$photodata = my_get_data_by_id('photo','biodata_id',$ey['biodata_id']);
		$photo = (file_exists($photodata['upload_path'])) ?'<a href="javascript:void;" onclick="jQuery.facebox({ image: \''.$photodata['upload_path'].'\' })"><img src="'.$photodata['upload_path'].'" height="30"   border="0"/></a>' :'<img src="files/upload/sample_thumb.jpg" height="30"   />' ;
		
		if(karyawan_resign($ey['karyawan_id'])){
		$row[] = array(
			'#'=>position_text_align ($i, 'center'),
			'photo'=>$photo, 
			'nik'=>position_text_align( '<font color="red">'. $ey['nik'] .'</font>', 'center'),
			'nama'=>'<font color="red">'.$ey['nama'].'</font>',  
			'jabatan'=> '<font color="red">'.$jbt_karya['nama_jabatan'].'</font>',  
			'divisi'=> '<font color="red">'.$jbt_karya['nama_devisi'] .'</font>',  
			'operasi'=> position_text_align( $detail_button .' '.$edit_button.' '.$delete_button , 'right'),  
		);
		}else{
		$row[] = array(
			'#'=>position_text_align ($i, 'center'),
			'photo'=>$photo, 
			'nik'=>position_text_align( $ey['nik'], 'center'),
			'nama'=>$ey['nama'],  
			//'usia'=>position_text_align(  date('Y') - date('Y' , strtotime($ey['tanggal_lahir'] ." 00:00:01") ) , 'center'), 
			'jabatan'=> $jbt_karya['nama_jabatan'],  
			'divisi'=> $jbt_karya['nama_devisi'] ,  
			'operasi'=> position_text_align( $detail_button .' '.$edit_button.' '.$delete_button , 'right'),  
		);
		}
	}
	
	$datas = table_rows($row);
	
	$viewemponly = ($oopps == '0') ? 'Active only' : 'All Karyawan' ;
	if(is_admin()):
	$menuontop = array(  
		$viewemponly=>array('onclick'=>'javascript:location.href=\'index.php?com=karyawan&task=set_opsi&val='. ($oopps == '0' ? '1':'0').'\''),
	//	'Tambah data'=>array('onclick'=>'javascript:location.href=\'index.php?com=karyawan&task=create\''),
		'Excel'=>array('onclick'=>'javascript:location.href=\'index.php?com='.$_GET['com'].'&task=excel_daftar_biodata\''),
	//	'Cetak' => array('onclick'=>'javascript:window.open(\'index.php?com=report&task=all_karyawan\',\'mywin\',\'left=20,top=20,width=800,height=600,toolbar=0,resizable=0\');')
	);
	else:
	
	$menuontop = array(  
		//'Tambah data'=>array('onclick'=>'javascript:location.href=\'index.php?com=karyawan&task=create\''),
		//'Export to excel'=>array('onclick'=>'javascript:location.href=\'index.php?com=csv&task=excel_daftar_karyawan\''),
		//'Cetak' => array('onclick'=>'javascript:window.open(\'index.php?com=report&task=all_karyawan\',\'mywin\',\'left=20,top=20,width=800,height=600,toolbar=0,resizable=0\');')
	);
	endif;
	
	$search = '<form method="GET"><input type="hidden" name="com" value="'.$_GET['com'].'" /><span style="font:10px verdana"><b>Pencarian cepat</b></span><br/><input type="text"  style="width:200px;" name="key" value="'.(isset($_GET['key']) ? $_GET['key']: "").'" /><input class="simple_search" type="submit" value=" CARI " /> </form>';
	$printmenu = additional_menu_on_list( $menuontop , $search);
	$paging = $kgPagerOBJ ->showPaging();
	return $printmenu . table_builder($header , $datas ,  15 ,false , $paging  );
} 

function report_calon_karyawan(){
my_set_code_js('
	function confirmDelete(i){
	var check = confirm(\'Akan mendelete data? \'); 
	if(check){
		location.href=\'index.php?com=karyawan&task=delete&id=\'+i;
	}
	return;	}
');

	$header = array(
		'#'=>array('style'=>'border-bottom:2px solid;width:5%'), 
		'pic'=>array('style'=>'border-bottom:2px solid;width:5%'),
		'no. agenda'=>array('style'=>'text-align:center;border-bottom:2px solid;width:15%'),   
		'nama'=>array('style'=>'border-bottom:2px solid;width:40%'),  
		'usia'=>array('style'=>'text-align:center;border-bottom:2px solid;width:10%'), 
		'interview'=>array('style'=>'border-bottom:2px solid;width:15%') ,
		' '=>array('style'=>'border-bottom:2px solid;width:15%'), 
	);
	$query = " 
			SELECT * FROM pelamar_seleksi x
			INNER JOIN pelamar y ON y.pelamar_id= x.pelamar_id  
			INNER JOIN biodata z ON y.biodata_id = z.biodata_id
			WHERE x.hasil='lulus' 	AND seleksi_pelamar_id = 5	
			
		
	";
	$query = "SELECT * FROM karyawan_disable x
	INNER JOIN karyawan y ON x.karyawan_id = y.karyawan_id
	INNER JOIN biodata z ON y.biodata_id = z.biodata_id
	INNER JOIN pelamar t ON t.pelamar_id= x.pelamar_id 
	INNER JOIN pelamar_seleksi m ON m.pelamar_id= t.pelamar_id 
	WHERE x.pelamar_id > 0 AND m.seleksi_pelamar_id = 5";
	$result = my_query($query );
	$total_records = my_num_rows($result );
	$scroll_page =5;  
	$per_page =15;  
	$current_page = isset($_GET['page']) ? (int) $_GET['page'] : 1 ; 
	if($current_page < 1){
		$current_page = 1;
	}		 
	$task = isset($_GET['task']) ? $_GET['task'] : '';
	$key = isset($_GET['key']) ? $_GET['key'] : '';
	$field = isset($_GET['field']) ? $_GET['field'] : '';
	$pager_url  ="index.php?com=karyawan&task={$task}&field={$field}&key={$key}&page=";	 
	$inactive_page_tag = 'style="padding:4px;background-color:#BBBBBB"';  
	$previous_page_text = ' Mundur '; 
	$next_page_text = ' Maju ';  
	$first_page_text = ' Awal '; 
	$last_page_text = ' Akhir ';
	
	
	$kgPagerOBJ = new kgPager();
			$kgPagerOBJ->pager_set(
				$pager_url, 
				$total_records, 
				$scroll_page, 
				$per_page, 
				$current_page, 
				$inactive_page_tag, 
				$previous_page_text, 
				$next_page_text, 
				$first_page_text, 
				$last_page_text ,$pager_url_last); 
	 		
	$result = my_query($query ." LIMIT ".$kgPagerOBJ->start.", ".$kgPagerOBJ->per_page); 	
	$row = array(); 
	$i = ($current_page  - 1 ) * 15; 
	while($ey = my_fetch_array($result )){
		$i++;
		
		/* EDIT */
		$editproperty_admin = array(
						'href'=>'index.php?com=karyawan&task=create_calon&id='.$ey['karyawan_id'], 
						'title'=>'Edit'
				);
		$edit_button_admin = button_icon( 'b_edit.png' , $editproperty_admin  );
		$editproperty_standar = array(
						'href'=>'javascript:;',
						'onclick'=>'alert(\'Akses di tolak\')',
						'title'=>'Edit'
				);
		$edit_button_standar = button_icon( 'b_edit.png' , $editproperty_standar  );
		$edit_button = admin_link( $edit_button_admin , $edit_button_standar );
		/* END EDIT*/
		/* EDIT */
		$editprofil_admin = array(
						'href'=>'index.php?com=profil_kepegawaian&task=edit&id='.$ey['karyawan_id'], 
						'title'=>'Edit profil kepegawaian'
				);
		$editprofil_button_admin = button_icon( 'b_usredit.png' , $editprofil_admin  );
		$editprofil_standar = array(
						'href'=>'javascript:;',
						'onclick'=>'alert(\'Akses di tolak\')',
						'title'=>'Edit profil kepegawaian'
				);
		$editprofil_button_standar = button_icon( 'b_usredit.png' , $editprofil_standar  );
		$editprofil_button = admin_link( $editprofil_button_admin , $editprofil_button_standar );
		/* END EDIT*/
		
		/* DELETE */
		$deleteproperty_admin = array(
						'href'=>'javascript:; ',
						'onclick'=>'javascript:confirmDelete('.$ey['karyawan_id'].');',
						'title'=>'Delete'
				);
		$delete_button_admin= button_icon( 'cut_on.gif' , $deleteproperty_admin  );
		$deleteproperty_standar = array(
						'href'=>'javascript:; ',
						'onclick'=>'javascript:alert(\'Akses ditolak\')',
						'title'=>'Delete'
				);
		$delete_button_standar= button_icon( 'cut_on.gif' , $deleteproperty_standar  );
		$delete_button = admin_link( $delete_button_admin , $delete_button_standar );
		/* END DELETE */
		
		
		$detailproperty = array(
						'href'=>'index.php?com=karyawan&task=detail&id='.$ey['karyawan_id'],
						'title'=>'Detail'
				);
		$detail_button = button_icon( 'b_props.png' , $detailproperty  );
		  
		 
		$photodata = my_get_data_by_id('photo','biodata_id',$ey['biodata_id']);
		$photo = (file_exists($photodata['upload_path'])) ?'<a href="javascript:void;" onclick="jQuery.facebox({ image: \''.$photodata['upload_path'].'\' })"><img src="'.$photodata['upload_path'].'" height="30"   border="0"/></a>' :'<img src="files/upload/sample_thumb.jpg" height="30"   />' ;
		$pelamar = my_get_data_by_id('pelamar','pelamar_id',$ey['pelamar_id']);
		$row[] = array(
			'#'=>position_text_align ($i, 'center'),
			'photo'=>$photo, 
			'nik'=>position_text_align( $ey['nomor_agenda'], 'center'),
			'nama'=>$ey['nama'],  
			'usia'=>position_text_align(   getage($ey['tanggal_lahir']) , 'center'),  
			'agenda'=> date('d-m-Y',strtotime($ey['tanggal_panggil'])) ,  
	 		'operasi'=> position_text_align( $detail_button /*.' '.$edit_button.' '.$delete_button */, 'right'),  
		);
	}
	
	$datas = table_rows($row);  
	if(is_admin()):
	$menuontop = array(  
		//'Tambah data'=>array('onclick'=>'javascript:location.href=\'index.php?com=karyawan&task=create_calon\''),
		//'Export to excel'=>array('onclick'=>'javascript:location.href=\'index.php?com=csv&task=excel_daftar_karyawan\''),
		'Cetak' => array('onclick'=>'javascript:window.open(\'index.php?com=report&task=all_karyawan\',\'mywin\',\'left=20,top=20,width=800,height=600,toolbar=0,resizable=0\');')
	);
	else:
	
	$menuontop = array(  
		//'Tambah data'=>array('onclick'=>'javascript:location.href=\'index.php?com=karyawan&task=create\''),
		//'Export to excel'=>array('onclick'=>'javascript:location.href=\'index.php?com=csv&task=excel_daftar_karyawan\''),
		'Cetak' => array('onclick'=>'javascript:window.open(\'index.php?com=report&task=all_karyawan\',\'mywin\',\'left=20,top=20,width=800,height=600,toolbar=0,resizable=0\');')
	);
	endif;
	
	$search = '<form method="POST"><span style="font:10px verdana"><b>Pencarian cepat</b></span><br/><input type="text"  style="width:200px;" name="key" /><input class="simple_search" type="submit" value=" CARI " /> </form>';
	$printmenu =  additional_menu_on_list( array() , $search);
	$paging = $kgPagerOBJ ->showPaging();
	return $printmenu . table_builder($header , $datas ,  15 ,false , $paging  );
} 

function move_uploaded_photo( $ori  , $biodata_id ){
	
	$filestype= array('jpg','gif','png','swf');
	$uploadfiletype = strtolower( end( explode("." , $ori['name']) ) );
	if( ! in_array($uploadfiletype , $filestype) ) return false;
	$newfilename =date('Ymd_his').'.'.$uploadfiletype;
	$path_upload = MY_FILES_PATH . $biodata_id . '/' . $newfilename;
	if(!file_exists(MY_FILES_PATH . $biodata_id))mkdir( MY_FILES_PATH . $biodata_id,0777);
	$upload_act = move_uploaded_file( $ori['tmp_name'] , $path_upload );
	
	if($upload_act ){
		
		$photo_datas = array(
			'biodata_id'=>my_type_data_int($biodata_id),
			'upload_path'=>my_type_data_str($path_upload)
		);
		return my_insert_record('photo' , $photo_datas);
	}
	
	return false;
}

function delete_photo($biodata_id){
	$photo = my_get_data_by_id('photo','biodata_id',$biodata_id);
	$path_upload = MY_FILES_PATH . $photo['biodata_id'] . '/' .$photo['upload_path'];
	if(file_exists($path_upload))@unlink($path_upload);
	$query = "DELETE FROM photo WHERE biodata_id ={$biodata_id}";
	return my_query($query);
}

function detail_entry($karyawan_id){
	$karyawan = loaddata_karyawan($karyawan_id);
	$view  = form_header( "detail karyawan" , "cp"  );
	$view .= form_field_display( '<span class="label_form">'.ucfirst($karyawan['nama']).'</span>'   , "<b>Nama pelamar</b>"    ); 
	$view .= form_field_display( '<span class="label_form">'.$karyawan['email'] .'</span>'  , "<b>Email</b>"    ); 
	$view .= form_field_display( '<span class="label_form">'.$karyawan['idcard'] .'</span>'  , "<b>Nomor identitas</b>"    );  
	$view .= form_field_display( '<span class="label_form">'.ucfirst($karyawan['kelamin']) .'</span>'  , "<b>Jenis kelamin</b>"    ); 
	$view .= form_field_display( '<span class="label_form">'.$karyawan['gol_da'] .'</span>'  , "<b>Golongan darah</b>"    ); 
	$view .= form_field_display( '<span class="label_form">'.ucfirst($karyawan['tempat_lahir'] ) .', '.   date('d M Y',strtotime($karyawan['tanggal_lahir'].' 00:00:01')).'</span>' , "<b>Tempat, tanggal lahir</b>"    ); 
	$view .= form_field_display( '<span class="label_form">'.$karyawan['marital'] .'</span>'  , "<b>Status perkawinan</b>"    ); 
	$view .= form_field_display( '<span class="label_form">'.$karyawan['agama']   .'</span>'  , "<b>Agama</b>"    );  
	$view .= form_field_display( '<span class="label_form">'.$karyawan['telepon_rumah'] .'</span>'  , "<b>Nomor telepon rumah</b>"    ); 
	$view .= form_field_display( '<span class="label_form">'.$karyawan['telepon_mobile'].'</span>'  , "<b>Nomor telepon seluler</b>"    ); 
	$view .= form_field_display( '<span class="label_form">'.nl2br($karyawan['alamat'] ).'</span>'  , "<b>Alamat</b>"    ); 
	$view .= form_field_display( '<span class="label_form">'.ucfirst($karyawan['kota'] ).'</span>'  , "<b>Kota</b>"    ); 
	$view .= form_field_display( '<span class="label_form">'.nl2br($karyawan['catatan'] ).'</span>'  , "<b>Catatan</b>"    ); 
	$submit = array(
		'value' => ( 'Lanjut'),
		'name' => 'simpan', 
		'type'=>'button',
		'onclick'=>'javascript:location.href=(\'index.php?com=profil_kepegawaian&task=create&id='.$karyawan_id.'\')',
		'class'=>'main_button'
	);
	$form_submit = form_dynamic($submit);
	$kk = array(
		'value' => ( 'Kembali'),
		'name' => 'simpan', 
		'type'=>'button',
		'onclick'=>'javascript:location.href=(\'index.php?com=karyawan\')',
		'class'=>'main_button'
	);
	$form_kk= form_dynamic($kk); 
	$ubah = array(
		'value' => ( 'Ubah'),
		'name' => 'simpan', 
		'type'=>'button',
		'onclick'=>'javascript:location.href=(\'index.php?com=karyawan&task=edit&id='.$karyawan_id.'&status=new\')',
		'class'=>'main_button'
	);
	$form_ubah= form_dynamic($ubah); 
	
	$view .= form_field_display( $form_kk .' '.$form_ubah  	  , "&nbsp;" ,  "" );	
	$view .= form_footer( ); 
	
	return $view;
}

function form_submit($id = 0){
	list($dd,$mm,$yyyy) = explode("-" , $_POST['tanggal_lahir']);
	$tanggal = $yyyy .'-'. $mm . '-' . $dd ;
	$lembur = isset($_POST['lembur']) ? 'Ya': 'Tidak';
	$datas = array(
		'idcard'=>my_type_data_str($_POST['tno'].'#'.strtoupper($_POST['idcard'])), 
		'nama'=>my_type_data_str($_POST['nama']),
		'gelar'=>my_type_data_str($_POST['gelar']),
		'panggilan'=>my_type_data_str($_POST['panggilan']), 
		'kelamin'=>my_type_data_str($_POST['kelamin']),
		'gol_da'=>my_type_data_str($_POST['gol_da']),
		'tempat_lahir'=>my_type_data_str($_POST['tempat_lahir']),
		'tanggal_lahir'=>my_type_data_str($tanggal),
		'marital'=>my_type_data_str($_POST['marital']),
		'agama'=>my_type_data_str($_POST['agama']),
		'nama_ibu'=>my_type_data_str($_POST['nama_ibu']),
		'alamat_cilegon'=>my_type_data_str($_POST['alamat_cilegon']),
		'alamat_ktp'=>my_type_data_str($_POST['alamat_ktp']),
		'kota_ktp'=>my_type_data_str($_POST['kota_ktp']),
		'email'=>my_type_data_str($_POST['email']), 
		'telepon_mobile'=>my_type_data_str($_POST['telepon_mobile']), 
		'tinggi_badan'=>my_type_data_str($_POST['tinggi_badan']),
		'asal_daerah'=>my_type_data_str($_POST['asal_daerah']),
		'berat_badan'=>my_type_data_str($_POST['berat_badan']), 
		'datetime_added'=>my_type_data_function('NOW()')
	); 
	if($id == 0){
		$biodata_id = my_insert_record('biodata' , $datas );
		move_uploaded_photo( $_FILES['photo']  , $biodata_id );
		
		$tanggalf = $yyyyf .'-'. $mmf . '-' . $ddf ;	
		$karyawan_datas =  array(
			'biodata_id'=>my_type_data_int($biodata_id), 
			'catatan'=>my_type_data_str($_POST['catatan']),
			'nik'=>my_type_data_str($_POST['nik'])
		);
		$karyawan_id = my_insert_record('karyawan' , $karyawan_datas );  
		create_data_karyawan_json($karyawan_id);	  
		return $karyawan_id;
	}else{
		$karyawan = my_get_data_by_id('karyawan','karyawan_id',$id); 
		my_update_record('biodata','biodata_id',$karyawan['biodata_id'],$datas);
		
		$karyawan_datas =  array(
			'biodata_id'=>my_type_data_int( $karyawan['biodata_id'] ), 
			'catatan'=>my_type_data_str($_POST['catatan'])
		);
		
		my_update_record('karyawan' , 'karyawan_id' , $id , $karyawan_datas );
		create_data_karyawan_json($id);
		if( isset($_GET['status'] ) )
			my_direct('index.php?com=karyawan&task=detail_entry_karyawan&id='.$id);
		 else 
			my_direct('index.php?com=karyawan&task=detail&id='.$id);
		 
		return true;
	}
}

function form_detail($id){
	my_set_code_js('
		function confirmDelete( task ,i){
		var check = confirm(\'Akan mendelete data? \'); 
		if(check){
			location.href=\'index.php?com=remove_node_karyawan&task=\'+ task +\'&id=\'+i;
		}
		return;	}
	');
	$karyawan = loaddata_karyawan($id); 
	$view = ' <div style="width:98%;text-align:right;">
	<input type="button" value=" CETAK " class="main_button" onclick="javascript:window.open(\'index.php?com=report&task=personal_resume&id='.$id.'\',\'mywin\',\'left=20,top=20,width=800,height=600,toolbar=0,resizable=0\');"/> 
	'.( is_calon($id) ?'' :' <input type="button" value=" ADMIN " class="main_button" onclick="javascript:location.href=\'index.php?com=kekaryawanan&task=detail&id='.$id.'\'"/>')
	.' <input type="button" value=" LIST " class="main_button" onclick="javascript:location.href=\'index.php?com=karyawan&page='.$_GET['page'].'\'"/>
	</div>'   ; 
	$view .= karyawan_header_detail($karyawan  );
	
	$aaaa = detail_header_view( );
	$aaaa .= detail_rows_view( 'Nomor identitas' , $karyawan['idcard'] );
	$aaaa .= detail_rows_view( 'NPWP' , $karyawan['npwp']);
	$aaaa .= detail_rows_view( 'Jamsostek' , $karyawan['jamsostek'] );
	$aaaa .= detail_rows_view( 'Email' , $karyawan['email']);
	$aaaa .= detail_rows_view( 'Golongan darah' , $karyawan['gol_da']   );
	$aaaa .= detail_rows_view( 'Agama' ,   ucfirst($karyawan['agama'] ) );
	$aaaa .= detail_rows_view( 'Status pernikahan' , ucfirst( $karyawan['marital'] ) );
	$aaaa .= detail_rows_view( 'Telepon mobile' , $karyawan['telepon_mobile'] );
//	$aaaa .= detail_rows_view( 'Alamat KTP' , nl2br( $karyawan['alamat'] ) );
//	$aaaa .= detail_rows_view( 'Kota KTP' , $karyawan['kota'] ); 
//	$aaaa .= detail_rows_view( 'Kodepos KTP' , $karyawan['kodepos'] ); 
//	$aaaa .= detail_rows_view( 'Alamat tinggal' , nl2br( $karyawan['alamat_tinggal'] ) );
//	$aaaa .= detail_rows_view( 'Kota tinggal' , $karyawan['kota_tinggal'] ); 
//	$aaaa .= detail_rows_view( 'Kodepos tinggal' , $karyawan['kodepos_tinggal'] ); 
	$aaaa .= detail_footer_view();
	
	$header = array(
		'#'=>array('style'=>'border-bottom:2px solid;width:15px'), 
		'tahun'=>array('style'=>'border-bottom:2px solid;width:70px'),  
		'penyakit'=>array('style'=>'border-bottom:2px solid;width:260px'),  
		'kesembuhan'=>array('style'=>'border-bottom:2px solid;width:160px'),     
		' '=>array('style'=>'border-bottom:2px solid;width:50px'),     
	);
	$n=1;
	$row =array();
	$ddatas = loaddata_kesehatan_karyawan( $id );
	foreach($ddatas as $ddata  ){ 
		$editproperty = array(
						'href'=>'index.php?com=riwayat_kesehatan&task=edit_popup&id='.$ddata['riwayat_kesehatan_id'], 
						'title'=>'Edit',
						'rel'=>'facebox'
				);
		$edit_button = button_icon( 'b_edit.png' , $editproperty  );
		$deleteproperty = array(
						'href'=>'javascript:void();', 
						'title'=>'Edit',
						'onclick'=>'javascript:confirmDelete(\'remove_kesehatan\', '.$ddata['riwayat_kesehatan_id'].')'
				);
		$delete_button = button_icon( 'b_drop.png' , $deleteproperty  );
		$delete_button = admin_link( $delete_button,'&nbsp;');
		$row[] = array(
			'#'=> $n,  
			'tahun'=>  $ddata['tahun_sakit'] , 
			'penyk'=>ucfirst($ddata['penyakit']) ,  
			'nik'=>  ucfirst($ddata['kesembuhan'] ),  
			'edit'=>position_text_align(  $edit_button .' '.$delete_button,'right')
		); $n++;
	}
	if($n < 5){
		for($y=$n; $y<=4; $y++){
		$row[] = array(
			'#'=>'&nbsp;',  
			'tahun'=>  '&nbsp;' , 
			'penyk'=>'&nbsp;' ,  
			'nik'=>  '&nbsp;', 
			'edit'=>  '&nbsp;', 
		); 
		}
	}
	$datas = table_rows_plain($row); 
	
	$bbbb = table_builder_plain($header , $datas ,  4 ,false );
	$bbbb  .= '<div style="text-align:right;width:100%;font:12px verdana;">'.admin_link('<a href="index.php?com=riwayat_kesehatan&kid='.$id.'&task=edit_popup&id=0" rel="facebox">[Tambah data]</a>').'</div>'; 
	
	$headercc = array(
		'#'=>array('style'=>'border-bottom:2px solid;width:15px'), 
		'nama'=>array('style'=>'border-bottom:2px solid;width:190px'),  
		'pekerjaan'=>array('style'=>'border-bottom:2px solid;width:130px'),  
		'usia'=>array('style'=>'border-bottom:2px solid;width:40px'),  
		'hubungan'=>array('style'=>'border-bottom:2px solid;width:100px'),   
		'pendidikan'=>array('style'=>'border-bottom:2px solid;width:80px'),   
		'tertanggung'=>array('style'=>'border-bottom:2px solid;width:100px'),   
		' '=>array('style'=>'border-bottom:2px solid;width:40px'),   
	);
	$ncc=1;
	$rowcc =array();
	
	$ddatascc = loaddata_keluarga_karyawan( $id ); 
	foreach($ddatascc as $ddatacc  ){ 
		$editproperty = array(
						'href'=>'index.php?com=data_keluarga&task=edit_popup&id='.$ddatacc['keluarga_karyawan_id'], 
						'title'=>'Edit',
						'rel'=>'facebox'
				);
		$edit_button = button_icon( 'b_edit.png' , $editproperty  );
		$deleteproperty = array(
						'href'=>'javascript:void();', 
						'title'=>'Edit',
						'onclick'=>'javascript:confirmDelete(\'remove_keluarga\', '.$ddatacc['keluarga_karyawan_id'].')'
				);
		$delete_button = button_icon( 'b_drop.png' , $deleteproperty  );
		$rowcc[] = array(
			'#'=> $ncc,  
			'nama'=>  ucfirst($ddatacc['nama']), 
			'pekerjaan'=>  ucfirst($ddatacc['pekerjaan']), 
			'usia'=>  (date('Y') - date('Y' , strtotime($ddatacc['tanggal_lahir'].' 00:00:01')) ),
			'hubungan'=>   ucfirst($ddatacc['label']),
			'pendidikan'=>strtoupper($ddatacc['pendidikan_terakhir'])   ,	
			'pe'=>   ucfirst($ddatacc['tertanggung']), 
			'edit'=>position_text_align(  $edit_button .' '.$delete_button,'right')
		); 
		$ncc++;
	}
	if($ncc < 5){
		for($ycc=$ncc; $ycc<=4; $ycc++){
		$rowcc[] = array(
			'#'=> '&nbsp;',  
			'nama'=>  '&nbsp;', 
			'sas'=>  '&nbsp;', 
			'usia'=> '&nbsp;',
			'hubungan'=>'&nbsp;' ,  
			'pekerjaan'=>'&nbsp;' ,  
			'pe'=>'&nbsp;', 
			'spe'=>'&nbsp;', 
		); 
		}
	}
	$datascc = table_rows_plain($rowcc); 
	$eeee  = table_builder_plain($headercc , $datascc ,  5,false ); 
	$eeee  .= '<div style="text-align:right;width:100%;font:12px verdana;">'.admin_link('<a href="index.php?com=data_keluarga&kid='.$id.'&task=edit_popup&id=0" rel="facebox">[Tambah data]</a>' ).'</div>'; 
	
	$headerccx = array(
		'#'=>array('style'=>'border-bottom:2px solid;width:15px'), 
		'nama pekerjaan'=>array('style'=>'border-bottom:2px solid;width:270px'),  
		'pada devisi'=>array('style'=>'border-bottom:2px solid;width:180px'),  
		'tahun'=>array('style'=>'border-bottom:2px solid;width:90px'),     
		'lokasi'=>array('style'=>'border-bottom:2px solid;width:190px'),     
		' '=>array('style'=>'border-bottom:2px solid;width:50px'),     
	);
	$nccx=1;
	$rowccx =array();
	
	$header_pendidikan = array(
		'#'=>array('style'=>'border-bottom:2px solid;width:15px'),  
		'Tahun'=>array('style'=>'border-bottom:2px solid;width:50px'),   
		'Jenjang'=>array('style'=>'border-bottom:2px solid;width:80px'),  
		'Nama lembaga'=>array('style'=>'border-bottom:2px solid;width:180px'), 
		'Ijazah'=>array('style'=>'border-bottom:2px solid;width:140px'),   
		'Nilai'=>array('style'=>'border-bottom:2px solid;width:80px'),   
		'kota'=>array('style'=>'border-bottom:2px solid;width:100px'),   
		'kategori'=>array('style'=>'border-bottom:2px solid;width:80px'),   
		' '=>array('style'=>'border-bottom:2px solid;width:50px'),   
	);
	$np=1;
	$rowpendidikans =array();
	$riwayat_pendidikans = loaddata_pendidikan_karyawan($id);
	foreach($riwayat_pendidikans as $riwayat_pendidikan  ){ 
	
		$editproperty = array(
						'href'=>'index.php?com=riwayat_pendidikan&task=edit_popup&id='.$riwayat_pendidikan['riwayat_pendidikan_id'], 
						'title'=>'Edit',
						'rel'=>'facebox'
				);
		$edit_button = button_icon( 'b_edit.png' , $editproperty  );
		$edit_button = admin_link($edit_button);
		$deleteproperty = array(
						'href'=>'javascript:void();', 
						'title'=>'Edit',
						'onclick'=>'javascript:confirmDelete(\'remove_pendidikan\', '.$riwayat_pendidikan['riwayat_pendidikan_id'].')'
				);
		$delete_button = button_icon( 'b_drop.png' , $deleteproperty  );
		$pend = my_get_data_by_id('pendidikan','pendidikan_id',$riwayat_pendidikan['pendidikan_id']);
		$rowpendidikan[] = array(
			'#'=> $np,  
			'tahun'=>   ucfirst($riwayat_pendidikan['tahun_masuk']),
			'jenjang'=>  strtoupper($pend['code']), 
			'nama_lembaga_pendidikan'=>  ucfirst($riwayat_pendidikan['nama_lembaga_pendidikan']),
			'ijazah'=>    $riwayat_pendidikan['no_ijazah'],
			'nilai'=>   $riwayat_pendidikan['nilai'] ,
			'kota'=>ucfirst($riwayat_pendidikan['lokasi_pendidikan'])   ,	
			'kategori'=>   strtoupper($riwayat_pendidikan['status_pendidikan']),   
			'edit'=>position_text_align( $edit_button.' '.$delete_button,'right')
		); 
		$np++;
	}
	if($np < 5){
		for($ycc=$np; $ycc<=4; $ycc++){
		$rowpendidikan[] = array(
			'#'=> '&nbsp;',  
			'nama'=>  '&nbsp;', 
			's'=>  '&nbsp;', 
			'd'=>  '&nbsp;', 
			'f'=>  '&nbsp;', 
			'usia'=> '&nbsp;',
			'hubungan'=>'&nbsp;' ,  
			'pekerjaan'=>'&nbsp;' ,  
			'pe'=>'&nbsp;', 
		); 
		}
	}
	
	$datapen = table_rows_plain($rowpendidikan); 
	$dddd =  table_builder_plain($header_pendidikan , $datapen ,  6 ,false );
	$dddd  .= '<div style="text-align:right;width:100%;font:12px verdana;">'.admin_link('<a href="index.php?com=riwayat_pendidikan&task=edit_popup&kid='.$id.'&id=0" rel="facebox">[Tambah data]</a>').'</div>'; 
	
	$header_kerja = array(
		'#'=>array('style'=>'border-bottom:2px solid;width:15px'),  
		'Tahun'=>array('style'=>'border-bottom:2px solid;width:200px'),   
		'Nama Perusahaan'=>array('style'=>'border-bottom:2px solid;width:350px'),  
		'Jabatan Terakhir'=>array('style'=>'border-bottom:2px solid;width:300px'),   
		' '=>array('style'=>'border-bottom:2px solid;width:50px'),   
	);
	$nk = 1;
	$rowkerjas =array();
	$riwayat_kerjas = loaddata_pekerjaan_karyawan($id);
	foreach($riwayat_kerjas as $riwayat_kerja  ){ 
	
		$editproperty = array(
						'href'=>'index.php?com=riwayat_kerja&task=edit_popup&id='.$riwayat_kerja['riwayat_kerja_id'], 
						'title'=>'Edit',
						'rel'=>'facebox'
				);
		$edit_button = button_icon( 'b_edit.png' , $editproperty  );
		$edit_button = admin_link($edit_button);
			
		$deleteproperty = array(
						'href'=>'javascript:void();', 
						'title'=>'Edit',
						'onclick'=>'javascript:confirmDelete(\'remove_riwayat_kerja\', '.$riwayat_kerja['riwayat_kerja_id'].')'
				);
		$delete_button = button_icon( 'b_drop.png' , $deleteproperty  );
		$delete_button = admin_link( $delete_button,'&nbsp;');
		$rowkerja[] = array(
			'#'=> $nk,   
			'tahun'			=> $riwayat_kerja['tahun_masuk']  .' s/d '. $riwayat_kerja['tahun_keluar'] ,
			'nama_perusahaan'=> strtoupper($riwayat_kerja['nama_perusahaan']),
			'jabatan_terakhir'			=> ucfirst($riwayat_kerja['jabatan_terakhir'])   ,	
			'edit'=>position_text_align( $edit_button.' '.$delete_button,'right')  
		); 
		$nk++;
	}
	if($nk < 5){
		for($ycc=$nk; $ycc<=4; $ycc++){
		$rowkerja[] = array(
			'#'=> '&nbsp;',  
			'nama'=>  '&nbsp;', 
			's'=>  '&nbsp;', 
			 'sd'=> '&nbsp;',
			'hubungan'=>'&nbsp;'  
		); 
		}
	}
	$dataker = table_rows_plain($rowkerja);  
	$ccccx = table_builder_plain($header_kerja , $dataker ,  5 ,false );
	$ccccx  .= '<div style="text-align:right;width:100%;font:12px verdana;">'.admin_link('<a href="index.php?com=riwayat_kerja&task=edit_popup&kid='.$id.'&id=0" rel="facebox">[Tambah data]</a>').'</div>'; 
	$cccc  = $ccccx ; 
	

	$header_hobi = array(
		'#'=>array('style'=>'border-bottom:2px solid;width:15px'),  
		'Kelompok'=>array('style'=>'border-bottom:2px solid;width:200px'),  
		'Hobi'=>array('style'=>'border-bottom:2px solid;width:350px'),     
		' '=>array('style'=>'border-bottom:2px solid;width:50px'),   
	);
	$hnccx3=1;
	$rowsthobi =array();
	$hobis = loaddata_hobi_karyawan($id);
	foreach($hobis as $hobi   ){ 
	
		$editproperty = array(
						'href'=>'index.php?com=hobi&task=edit_popup&id='.$hobi['hobi_id'], 
						'title'=>'Edit',
						'rel'=>'facebox'
				);
		$edit_button = button_icon( 'b_edit.png' , $editproperty  );
		$edit_button = admin_link($edit_button); 
		
		$deleteproperty = array(
						'href'=>'javascript:void();', 
						'title'=>'Edit',
						'onclick'=>'javascript:confirmDelete(\'remove_hobi\', '.$hobi['hobi_id'].')'
				);
		$delete_button = button_icon( 'b_drop.png' , $deleteproperty  );
		$delete_button = admin_link( $delete_button,'&nbsp;');
		$rowsthobi[] = array(
			'#'=> $hnccx3,  
			'kelompok'=> $hobi['label'],  
			'hobi'=> $hobi['nama_hobi']      ,	 
			'edit'=>position_text_align( $edit_button.' '.$delete_button,'right')  			
		); 
		$hnccx3++;
	}
	if($hnccx3 < 5){
		for($ycc=$hnccx3; $ycc<=4; $ycc++){
		$rowsthobi[] = array(
			'#'=> '&nbsp;',  
			's'=> '&nbsp;',   
			'usia'=> '&nbsp;', 
			' '=>'&nbsp;', 
		); 
		}
	}
	
	$stshobi = table_rows_plain($rowsthobi); 
	$hobi_table .= table_builder_plain($header_hobi , $stshobi ,  4,false );
	$hobi_table  .= '<div style="text-align:right;width:100%;font:12px verdana;">'.admin_link('<a href="index.php?com=hobi&task=edit_popup&kid='.$id.'&id=0" rel="facebox">[Tambah data]</a>').'</div>'; 

	
	$tab_options = array(
		'Detail'=>'tab1',
		'Kesehatan'=>'tab2',
		'Kontak'=>'tab7',
		'Riwayat kerja'=>'tab3',
		'Pendidikan'=>'tab4', 
		'Minat'=>'tab6',
		'Data keluarga'=>'tab5'
		);
	$contents = array(
		'tab1'=>$aaaa,
		'tab7'=>alamat_karyawan($id),
		'tab2'=>$bbbb,
		'tab3'=>$cccc ,
		'tab4'=>$dddd.'<br />'.table_riwayat_pelatihan($id),
		'tab6'=> $hobi_table,
		'tab5'=>$eeee);
	$tabcontents = tab_page($tab_options , $contents );
	return $view.$tabcontents ;
	
	
}

function form_detail_pelamar($id){
my_set_code_js('
	function confirmDelete( task ,i){
	var check = confirm(\'Akan mendelete data? \'); 
	if(check){
		location.href=\'index.php?com=remove_node_karyawan&task=\'+ task +\'&id=\'+i;
	}
	return;	}
');
	$karyawan = loaddata_karyawan($id); 
	$photo = my_get_data_by_id('photo','biodata_id',$karyawan['biodata_id']);
	$view ='<table width="98%" cellspacing="0" cellpadding="4"><tr><td width="15%" align="center" style="background:#CDCDCD">';
	if(file_exists($photo['upload_path']))
		$view .= '<img src="'.$photo['upload_path'].'" width="120px" height="160px"/><br/>';
	else
		$view .= '<img src="files/upload/sample_thumb.jpg" width="120px" height="160px"/><br/>';
		
	$view_admin  = '<a href="index.php?com=karyawan&task=ganti_photo&id='.$id.'" rel="facebox" style="font:10px verdana;">[Ganti photo]</a>	';
	if(is_admin())$view .=$view_admin;
	$view .='</td><td width="85%" align="left" valign="bottom">';
	$view .= form_header( "detail pegawai" , "cp"  );
	$view .= '<tr><td><td><div style="width:100%;text-align:right;">
	<input type="button" value=" CETAK " class="main_button" onclick="javascript:window.open(\'index.php?com=report&task=personal_resume&id='.$id.'\',\'mywin\',\'left=20,top=20,width=800,height=600,toolbar=0,resizable=0\');"/> 
	'.( is_calon($id) ?'' :' <input type="button" value=" KARIR " class="main_button" onclick="javascript:location.href=\'index.php?com=kekaryawanan&task=detail&id='.$id.'\'"/>')
	.' <input type="button" value=" LIST " class="main_button" onclick="javascript:location.href=\'index.php?com=karyawan&task=calon\'"/>
	</div></td></tr>'   ; 
	$view .= form_field_display( '<span class="label_form">'.ucfirst($karyawan['nama']).'</span>'   , "<b>Nama pelamar</b>"    ); 
	$karyawan_disable = my_get_data_by_id('karyawan_disable','karyawan_id',$id);
	$agenda = my_get_data_by_id('pelamar','pelamar_id', $karyawan_disable['pelamar_id']);
	$view .= form_field_display( '<span class="label_form">'.$agenda['nomor_agenda'] .'</span>'  , "<b>Nomor agenda</b>"    ); 
	$view .= form_field_display( '<span class="label_form">'.date('d-m-Y',strtotime($karyawan['tanggal_kontrak'] )).'</span>'  , "<b>Tanggal agenda</b>"    ); 
	$view .= form_field_display( '<span class="label_form">'.ucfirst($karyawan['kelamin'] ) .'</span>'  , "<b>Jenis kelamin</b>"    ); 
	$view .= form_field_display( '<span class="label_form">'.ucfirst($karyawan['tempat_lahir'] ) .', '.   date('d M Y',strtotime($karyawan['tanggal_lahir'].' 00:00:01')).'</span>' , "<b>Tempat, tanggal lahir</b>"    ); 
	//$view .= form_field_display( '<span class="label_form">'.ucfirst($karyawan['devisi'] ) .' <b>/</b> '.$karyawan['jabatan'] .'</span>'  , "<b>Devisi / Jabatan</b>"    ); 
	$view .= form_footer( );
	$view .= '</td></tr></table>';
	
	
	$aaaa = detail_header_view( );
	$aaaa .= detail_rows_view( 'Nomor identitas' , $karyawan['idcard'] );
//	$aaaa .= detail_rows_view( 'NPWP' , $karyawan['npwp']);
	$aaaa .= detail_rows_view( 'Email' , $karyawan['email']);
	$aaaa .= detail_rows_view( 'Golongan darah' , $karyawan['gol_da']   );
	$aaaa .= detail_rows_view( 'Agama' ,   ucfirst($karyawan['agama'] ) );
	$aaaa .= detail_rows_view( 'Status pernikahan' , ucfirst( $karyawan['marital'] ) );
//	$aaaa .= detail_rows_view( 'Telepon rumah' , $karyawan['telepon_rumah'] );
	$aaaa .= detail_rows_view( 'Telepon  ' , $karyawan['telepon_mobile'] );
//	$aaaa .= detail_rows_view( 'Alamat KTP' , nl2br( $karyawan['alamat'] ) );
//	$aaaa .= detail_rows_view( 'Kota KTP' , $karyawan['kota'] ); 
//	$aaaa .= detail_rows_view( 'Kodepos KTP' , $karyawan['kodepos'] ); 
//	$aaaa .= detail_rows_view( 'Alamat tinggal' , nl2br( $karyawan['alamat_tinggal'] ) );
//	$aaaa .= detail_rows_view( 'Kota tinggal' , $karyawan['kota_tinggal'] ); 
//	$aaaa .= detail_rows_view( 'Kodepos tinggal' , $karyawan['kodepos_tinggal'] ); 
	$aaaa .= detail_footer_view();
	
	$header = array(
		'#'=>array('style'=>'border-bottom:2px solid;width:15px'), 
		'tahun'=>array('style'=>'border-bottom:2px solid;width:70px'),  
		'penyakit'=>array('style'=>'border-bottom:2px solid;width:260px'),  
		'kesembuhan'=>array('style'=>'border-bottom:2px solid;width:160px'),     
		' '=>array('style'=>'border-bottom:2px solid;width:50px'),     
	);
	$n=1;
	$row =array();
	$ddatas = loaddata_kesehatan_karyawan( $id );
	foreach($ddatas as $ddata  ){ 
		$editproperty = array(
						'href'=>'index.php?com=riwayat_kesehatan&task=edit_popup&id='.$ddata['riwayat_kesehatan_id'], 
						'title'=>'Edit',
						'rel'=>'facebox'
				);
		$edit_button = button_icon( 'b_edit.png' , $editproperty  );
		$deleteproperty = array(
						'href'=>'javascript:void();', 
						'title'=>'Edit',
						'onclick'=>'javascript:confirmDelete(\'remove_kesehatan\', '.$ddata['riwayat_kesehatan_id'].')'
				);
		$delete_button = button_icon( 'b_drop.png' , $deleteproperty  );
		$delete_button = admin_link( $delete_button,'&nbsp;');
		$row[] = array(
			'#'=> $n,  
			'tahun'=>  $ddata['tahun_sakit'] , 
			'penyk'=>ucfirst($ddata['penyakit']) ,  
			'nik'=>  ucfirst($ddata['kesembuhan'] ),  
			'edit'=>position_text_align(  $edit_button .' '.$delete_button,'right')
		); $n++;
	}
	if($n < 5){
		for($y=$n; $y<=4; $y++){
		$row[] = array(
			'#'=>'&nbsp;',  
			'tahun'=>  '&nbsp;' , 
			'penyk'=>'&nbsp;' ,  
			'nik'=>  '&nbsp;', 
			'edit'=>  '&nbsp;', 
		); 
		}
	}
	$datas = table_rows_plain($row); 
	
	$bbbb = table_builder_plain($header , $datas ,  4 ,false );
	$bbbb  .= '<div style="text-align:right;width:100%;font:12px verdana;">'.admin_link('<a href="index.php?com=riwayat_kesehatan&kid='.$id.'&task=edit_popup&id=0" rel="facebox">[Tambah data]</a>').'</div>'; 
	
	$headercc = array(
		'#'=>array('style'=>'border-bottom:2px solid;width:15px'), 
		'nama'=>array('style'=>'border-bottom:2px solid;width:190px'),  
		'pekerjaan'=>array('style'=>'border-bottom:2px solid;width:130px'),  
		'usia'=>array('style'=>'border-bottom:2px solid;width:40px'),  
		'hubungan'=>array('style'=>'border-bottom:2px solid;width:100px'),   
		'pendidikan'=>array('style'=>'border-bottom:2px solid;width:80px'),   
		'tertanggung'=>array('style'=>'border-bottom:2px solid;width:100px'),   
		' '=>array('style'=>'border-bottom:2px solid;width:40px'),   
	);
	$ncc=1;
	$rowcc =array();
	
	$ddatascc = loaddata_keluarga_karyawan( $id ); 
	foreach($ddatascc as $ddatacc  ){ 
		$editproperty = array(
						'href'=>'index.php?com=data_keluarga&task=edit_popup&id='.$ddatacc['keluarga_karyawan_id'], 
						'title'=>'Edit',
						'rel'=>'facebox'
				);
		$edit_button = button_icon( 'b_edit.png' , $editproperty  );
		$deleteproperty = array(
						'href'=>'javascript:void();', 
						'title'=>'Edit',
						'onclick'=>'javascript:confirmDelete(\'remove_keluarga\', '.$ddatacc['keluarga_karyawan_id'].')'
				);
		$delete_button = button_icon( 'b_drop.png' , $deleteproperty  );
		$rowcc[] = array(
			'#'=> $ncc,  
			'nama'=>  ucfirst($ddatacc['nama']), 
			'pekerjaan'=>  ucfirst($ddatacc['pekerjaan']), 
			'usia'=>  (date('Y') - date('Y' , strtotime($ddatacc['tanggal_lahir'].' 00:00:01')) ),
			'hubungan'=>   ucfirst($ddatacc['label']),
			'pendidikan'=>strtoupper($ddatacc['pendidikan_terakhir'])   ,	
			'pe'=>   ucfirst($ddatacc['tertanggung']), 
			'edit'=>position_text_align(  $edit_button .' '.$delete_button,'right')
		); 
		$ncc++;
	}
	if($ncc < 5){
		for($ycc=$ncc; $ycc<=4; $ycc++){
		$rowcc[] = array(
			'#'=> '&nbsp;',  
			'nama'=>  '&nbsp;', 
			'sas'=>  '&nbsp;', 
			'usia'=> '&nbsp;',
			'hubungan'=>'&nbsp;' ,  
			'pekerjaan'=>'&nbsp;' ,  
			'pe'=>'&nbsp;', 
			'spe'=>'&nbsp;', 
		); 
		}
	}
	$datascc = table_rows_plain($rowcc); 
	$eeee  = table_builder_plain($headercc , $datascc ,  5,false ); 
	$eeee  .= '<div style="text-align:right;width:100%;font:12px verdana;">'.admin_link('<a href="index.php?com=data_keluarga&kid='.$id.'&task=edit_popup&id=0" rel="facebox">[Tambah data]</a>' ).'</div>'; 
	
	$headerccx = array(
		'#'=>array('style'=>'border-bottom:2px solid;width:15px'), 
		'nama pekerjaan'=>array('style'=>'border-bottom:2px solid;width:270px'),  
		'pada devisi'=>array('style'=>'border-bottom:2px solid;width:180px'),  
		'tahun'=>array('style'=>'border-bottom:2px solid;width:90px'),     
		'lokasi'=>array('style'=>'border-bottom:2px solid;width:190px'),     
		' '=>array('style'=>'border-bottom:2px solid;width:50px'),     
	);
	$nccx=1;
	$rowccx =array();
	
	$header_pendidikan = array(
		'#'=>array('style'=>'border-bottom:2px solid;width:15px'),  
		'Tahun'=>array('style'=>'border-bottom:2px solid;width:50px'),   
		'Jenjang'=>array('style'=>'border-bottom:2px solid;width:80px'),  
		'Nama lembaga'=>array('style'=>'border-bottom:2px solid;width:180px'), 
		'Ijazah'=>array('style'=>'border-bottom:2px solid;width:140px'),   
		'Nilai'=>array('style'=>'border-bottom:2px solid;width:80px'),   
		'kota'=>array('style'=>'border-bottom:2px solid;width:100px'),   
		'kategori'=>array('style'=>'border-bottom:2px solid;width:80px'),   
		' '=>array('style'=>'border-bottom:2px solid;width:50px'),   
	);
	$np=1;
	$rowpendidikans =array();
	$riwayat_pendidikans = loaddata_pendidikan_karyawan($id);
	foreach($riwayat_pendidikans as $riwayat_pendidikan  ){ 
	
		$editproperty = array(
						'href'=>'index.php?com=riwayat_pendidikan&task=edit_popup&id='.$riwayat_pendidikan['riwayat_pendidikan_id'], 
						'title'=>'Edit',
						'rel'=>'facebox'
				);
		$edit_button = button_icon( 'b_edit.png' , $editproperty  );
		$edit_button = admin_link($edit_button);
		$deleteproperty = array(
						'href'=>'javascript:void();', 
						'title'=>'Edit',
						'onclick'=>'javascript:confirmDelete(\'remove_pendidikan\', '.$riwayat_pendidikan['riwayat_pendidikan_id'].')'
				);
		$delete_button = button_icon( 'b_drop.png' , $deleteproperty  );
		$pend = my_get_data_by_id('pendidikan','pendidikan_id',$riwayat_pendidikan['pendidikan_id']);
		$rowpendidikan[] = array(
			'#'=> $np,  
			'tahun'=>   ucfirst($riwayat_pendidikan['tahun_masuk']),
			'jenjang'=>  strtoupper($pend['code']), 
			'nama_lembaga_pendidikan'=>  ucfirst($riwayat_pendidikan['nama_lembaga_pendidikan']),
			'ijazah'=>    $riwayat_pendidikan['no_ijazah'],
			'nilai'=>   $riwayat_pendidikan['nilai'] ,
			'kota'=>ucfirst($riwayat_pendidikan['lokasi_pendidikan'])   ,	
			'kategori'=>   strtoupper($riwayat_pendidikan['status_pendidikan']),   
			'edit'=>position_text_align( $edit_button.' '.$delete_button,'right')
		); 
		$np++;
	}
	if($np < 5){
		for($ycc=$np; $ycc<=4; $ycc++){
		$rowpendidikan[] = array(
			'#'=> '&nbsp;',  
			'nama'=>  '&nbsp;', 
			's'=>  '&nbsp;', 
			'd'=>  '&nbsp;', 
			'f'=>  '&nbsp;', 
			'usia'=> '&nbsp;',
			'hubungan'=>'&nbsp;' ,  
			'pekerjaan'=>'&nbsp;' ,  
			'pe'=>'&nbsp;', 
		); 
		}
	}
	
	$datapen = table_rows_plain($rowpendidikan); 
	$dddd =  table_builder_plain($header_pendidikan , $datapen ,  6 ,false );
	$dddd  .= '<div style="text-align:right;width:100%;font:12px verdana;">'.admin_link('<a href="index.php?com=riwayat_pendidikan&task=edit_popup&kid='.$id.'&id=0" rel="facebox">[Tambah data]</a>').'</div>'; 
	
	$header_kerja = array(
		'#'=>array('style'=>'border-bottom:2px solid;width:15px'),  
		'Nama perusahaan'=>array('style'=>'border-bottom:2px solid;width:180px'),  
		'Tahun'=>array('style'=>'border-bottom:2px solid;width:90px'),   
		'kota'=>array('style'=>'border-bottom:2px solid;width:80px'),   
		'bidang'=>array('style'=>'border-bottom:2px solid;width:160px'),   
		' '=>array('style'=>'border-bottom:2px solid;width:50px'),   
	);
	$nk = 1;
	$rowkerjas =array();
	$riwayat_kerjas = loaddata_pekerjaan_karyawan($id);
	foreach($riwayat_kerjas as $riwayat_kerja  ){ 
	
		$editproperty = array(
						'href'=>'index.php?com=riwayat_kerja&task=edit_popup&id='.$riwayat_kerja['riwayat_kerja_id'], 
						'title'=>'Edit',
						'rel'=>'facebox'
				);
		$edit_button = button_icon( 'b_edit.png' , $editproperty  );
		$edit_button = admin_link($edit_button);		
		$deleteproperty = array(
						'href'=>'javascript:void();', 
						'title'=>'Edit',
						'onclick'=>'javascript:confirmDelete(\'remove_riwayat_kerja\', '.$riwayat_kerja['riwayat_kerja_id'].')'
				);
		$delete_button = button_icon( 'b_drop.png' , $deleteproperty  );
		$delete_button = admin_link( $delete_button,'&nbsp;');
		$rowkerja[] = array(
			'#'=> $nk,   
			'nama_perusahaan'=> strtoupper($riwayat_kerja['nama_perusahaan']),
			'tahun'			=> $riwayat_kerja['tahun_masuk']  .' s/d '. $riwayat_kerja['tahun_keluar'] ,
			'kota'			=> ucfirst($riwayat_kerja['lokasi_kerja'])   ,	
			'bidang'		=> strtoupper($riwayat_kerja['bidang_kerja']),  
			'edit'=>position_text_align( $edit_button.' '.$delete_button ,'right')  
		); 
		$nk++;
	}
	if($nk < 5){
		for($ycc=$nk; $ycc<=4; $ycc++){
		$rowkerja[] = array(
			'#'=> '&nbsp;',  
			'nama'=>  '&nbsp;', 
			's'=>  '&nbsp;', 
			'usia'=> '&nbsp;',
			'sd'=> '&nbsp;',
			'hubungan'=>'&nbsp;'  
		); 
		}
	}
	$dataker = table_rows_plain($rowkerja);  
	$ccccx = table_builder_plain($header_kerja , $dataker ,  5 ,false );
	$ccccx  .= '<div style="text-align:right;width:100%;font:12px verdana;">'.admin_link('<a href="index.php?com=riwayat_kerja&task=edit_popup&kid='.$id.'&id=0" rel="facebox">[Tambah data]</a>').'</div>'; 
	$cccc  = $ccccx ; 

	$header_hobi = array(
		'#'=>array('style'=>'border-bottom:2px solid;width:15px'),  
		'Kelompok'=>array('style'=>'border-bottom:2px solid;width:200px'),  
		'Hobi'=>array('style'=>'border-bottom:2px solid;width:350px'),     
		' '=>array('style'=>'border-bottom:2px solid;width:50px'),   
	);
	$hnccx3=1;
	$rowsthobi =array();
	$hobis = loaddata_hobi_karyawan($id);
	foreach($hobis as $hobi   ){ 
	
		$editproperty = array(
						'href'=>'index.php?com=hobi&task=edit_popup&id='.$hobi['hobi_id'], 
						'title'=>'Edit',
						'rel'=>'facebox'
				);
		$edit_button = button_icon( 'b_edit.png' , $editproperty  );
		$edit_button = admin_link($edit_button); 
		$rowsthobi[] = array(
			'#'=> $hnccx3,  
			'kelompok'=> $hobi['label'],  
			'hobi'=> $hobi['nama_hobi']      ,	 
			'edit'=>position_text_align( $edit_button,'right')  			
		); 
		$hnccx3++;
	}
	if($hnccx3 < 5){
		for($ycc=$hnccx3; $ycc<=4; $ycc++){
		$rowsthobi[] = array(
			'#'=> '&nbsp;',  
			's'=> '&nbsp;',   
			'usia'=> '&nbsp;', 
			' '=>'&nbsp;', 
		); 
		}
	}
	
	$stshobi = table_rows_plain($rowsthobi); 
	$hobi_table .= table_builder_plain($header_hobi , $stshobi ,  4,false );
	$hobi_table  .= '<div style="text-align:right;width:100%;font:12px verdana;">'.admin_link('<a href="index.php?com=hobi&task=edit_popup&kid='.$id.'&id=0" rel="facebox">[Tambah data]</a>').'</div>'; 

	
	$tab_options = array(
		'Detail'=>'tab1',
		'Kesehatan'=>'tab2',
		'Kontak'=>'tab7',
		'Riwayat kerja'=>'tab3',
		'Pendidikan'=>'tab4', 
		'Minat'=>'tab6',
		'Data keluarga'=>'tab5'
		);
	$contents = array(
		'tab1'=>$aaaa,
		'tab7'=>alamat_karyawan($id),
		'tab2'=>$bbbb,
		'tab3'=>$cccc ,
		'tab4'=>$dddd.'<br />'.table_riwayat_pelatihan($id),
		'tab6'=> $hobi_table,
		'tab5'=>$eeee);
	$tabcontents = tab_page($tab_options , $contents );
	return $view.$tabcontents ;
	
	
}

function form_submit_validate(){
	$errsubmit = false;
	$err = array();
	
	/*CHECK CODE*/
	$nik =  trim($_POST["nik"]); 
	$data_code = my_query("SELECT karyawan_id FROM karyawan WHERE nik='{$nik}' "); 
	
	if( $nik == ''){
		//$errsubmit = true;
		$err[] = "Nomor induk pegawai belum di isi";
	}
	elseif(my_num_rows($data_code) > 0){
		//$errsubmit = true;
		$err[] = "Nomor induk pegawai  sudah digunakan";	
	}
	
	if( ! valid_name ($_POST['nama'])   ){
		$errsubmit = true;
		$err[] = "Nama karyawan belum benar";	
	}
	
	if( trim($_POST['kelamin']) == ''){
		$errsubmit = true;
		$err[] = "Jenis kelamin belum di pilih";	
	}
	
	list($dd,$mm,$yyy) = explode( "-" , $_POST['tanggal_lahir'] );
	$umur = getage($yyy.'-'.$mm.'-'.$dd);
	if( $umur  < 18 ){
		$errsubmit = true;
		$err[] = "Usia karyawan tidak memenuhi syarat ( {$umur}thn dari minimal 18thn )";	
	}
	
	if( $errsubmit){
		return $err;
	}
	
	return $errsubmit;
}


function form_create($id =0){
	my_set_file_js(array('components/system/js/calendar/calendarDateInput.js','components/system/jquery/combomulti/jquery.chainedSelects.js')); 
	my_set_code_js(' 
	$(function()
	{ 
		$(\'#devisi_id\').chainSelect(\'#jabatan_id\',\'combobox_jabatan.php\',
		{ 
			before:function (target) 
			{ 
				$("#jabatanloading").css("display","block");
				$("#defaultjabatan").css("display","none");
				$(target).css("display","none");
			},
			after:function (target) 
			{ 
				$("#jabatanloading").css("display","none");
				$("#defaultjabatan").css("display","none");
				$(target).css("display","inline");
			}
		});
	});

	' );
	my_set_code_css('
	#jabatanloading
		{  
			background:#ff0000;
			color:#fff;
			font-size:14px;
			font-familly:Arial;
			padding:2px; 
			display:none;
			float:left;
		}
	');
	$fields =  loaddata_karyawan($id);  
	$view = form_header( "calon pegawai" , "cp"  );
 //	if($id == 0){
	 $nomor = array(
				'name'=>'nik',
				'value'=>( isset($_POST['nik']) ? $_POST['nik'] : $fields['nik'] ), 
				'id'=>'nik',
				'type'=>'text',
				'size'=>'35', 
			);
	$form_field_no= form_dynamic($nomor);
	$view .= form_field_display( $form_field_no   , "Nomor induk karyawan"    ); 
//	}
	$nama = array(
				'name'=>'nama',
				'value'=>( isset($_POST['nama']) ? $_POST['nama'] : $fields['nama'] ),
				'id'=>'nama',
				'type'=>'text',
				'size'=>'45'
			);
	$form_field_nama = form_dynamic($nama); 
	$view .= form_field_display( $form_field_nama   , "Nama"   );
	
	$gelar = array(
				'name'=>'gelar',
				'value'=>( isset($_POST['gelar']) ? $_POST['gelar'] : $fields['gelar'] ),
				'id'=>'gelar',
				'type'=>'text',
				'size'=>'45'
			);
	$form_field_gelar = form_dynamic($gelar); 
	$view .= form_field_display( $form_field_gelar   , "Gelar"   );
	
	$panggilan = array(
				'name'=>'panggilan',
				'value'=>( isset($_POST['panggilan']) ? $_POST['panggilan'] : $fields['panggilan'] ),
				'id'=>'panggilan',
				'type'=>'text',
				'size'=>'45'
			);
	$form_field_panggilan = form_dynamic($panggilan);
	
	$view .= form_field_display( $form_field_panggilan    , "Panggilan"   );
	
	$nama_ibu = array(
				'name'=>'nama_ibu',
				'value'=>( isset($_POST['nama_ibu']) ? $_POST['nama_ibu'] : $fields['nama_ibu'] ),
				'id'=>'nama_ibu',
				'type'=>'text',
				'size'=>'45'
			);
	$form_field_nama_ibu = form_dynamic($nama_ibu);
	
	$view .= form_field_display( $form_field_nama_ibu    , "Nama ibu kandung"   );
	if($id ==0):
	$photo = array(
				'name'=>'photo',
				'value'=>'',
				'id'=>'photo',
				'type'=>'file',
				'size'=>'45'
			);
	$form_field_photo = form_dynamic($photo);
	
	$view .= form_field_display( $form_field_photo   , "Photo"   );
	endif;
	
	$email = array(
				'name'=>'email',
				'value'=>( isset($_POST['email']) ? $_POST['email'] : $fields['email'] ),
				'id'=>'email',
				'type'=>'text','size'=>'35' 
			);
	$form_field_email = form_dynamic($email);
	$view .= form_field_display( $form_field_email   , "Email"    );
	
	list($tno,$numberid)=explode('#',$fields['idcard']);
	$types= array(
			'KTP'=>'KTP',
			'SIM'=>'SIM',
			'PASSPORT'=>'PASSPORT',
			'KITAS'=>'KITAS',
		);
	$type = array(
			'name'=>'tno',
			'id'=>'tno',
			'value'=>isset($_POST['tno']) ? $_POST['tno'] :$tno,
	
		);
	$form_tpye = form_dropdown( $type , $types );
	$idcard = array(
				'name'=>'idcard',
				'value'=>( isset($_POST['idcard']) ? $_POST['idcard'] : $numberid ),
				'id'=>'idcard',
				'type'=>'text','size'=>'35' 
			);
	$form_field_idcard = form_dynamic($idcard);
	$view .= form_field_display( $form_tpye . $form_field_idcard   , "Nomor Identitas"    );
	
	 
	$datas = array(
		'laki-laki'=>'Laki-laki',
		'perempuan'=>'Perempuan'
	);
	 $kelamin = array(
				'name'=>'kelamin',
				'value'=>( isset($_POST['kelamin']) ? $_POST['kelamin'] : $fields['kelamin'] ),
				'id'=>'kelamin', 
			);
	$form_field_kelamin = form_radiobutton($kelamin , $datas  );
	$view .= form_field_display( $form_field_kelamin   , "Jenis kelamin"    );
	
	
	$datas = array(
			'O'=>'O',
			'A'=>'A',
			'B'=>'B',
			'AB'=>'AB' 
		);
	 $golda = array(
				'name'=>'gol_da',
				'value'=>( isset($_POST['gol_da']) ? $_POST['gol_da'] : $fields['gol_da'] ),
				'id'=>'gol_da', 
			);
	$form_field_golda = form_dropdown($golda , $datas);
	$view .= form_field_display( $form_field_golda  , "Golongan darah"    );

	$query = "SELECT * FROM kota ORDER BY nama_kota ASC";
	$result = my_query($query);
	$temps = array();
	while( $r = my_fetch_array($result) ){
		$temps[$r['kota_id']] =$r['nama_kota'];
	}	
	$temp = array(
		'name'=>'tempat_lahir',
		'value'=>( isset($_POST['tempat_lahir'] ) ? $_POST['tempat_lahir'] : $fields['kota_id']  ),
		'id'=>'tempat_lahir',   
	);
	$form_temp = form_dropdown($temp , $temps );
	$view .= form_field_display( $form_temp , "Tempat kelahiran"    );
 
	$tanggal_lahir = array(
				'name'=>'tanggal_lahir',
				'value'=>( isset($_POST['tanggal_lahir']) ? $_POST['tanggal_lahir'] : ( ( $fields['tanggal_lahir'] <> '') ? date('d-m-Y' , strtotime($fields['tanggal_lahir']) ) : '01-01-1980') ),
				'id'=>'tanggal_lahir',
				'type'=>'text','size'=>'55' 
			);
	$form_field_tanggal_lahir = form_calendar ($tanggal_lahir);
	$view .= form_field_display( $form_field_tanggal_lahir   , "Tanggal kelahiran"    );
	$datas = array(
			'Belum Nikah'=>'Belum Nikah',
			'Nikah'=>'Nikah',
			'Duda'=>'Duda',
			'Janda'=>'Janda' 
		);
	 $marital = array(
				'name'=>'marital',
				'value'=>( isset($_POST['marital']) ? $_POST['marital'] : $fields['marital'] ),
				'id'=>'marital', 
			);
	$form_field_marital = form_dropdown($marital , $datas);
	$view .= form_field_display( $form_field_marital   , "Status perkawinan"    );
	
	$datasagama = array(
			'islam'=>'Islam',
			'kristen'=>'Kristen',
			'katolik'=>'Katolik',
			'hindu'=>'Hindu' ,
			'budha'=>'Budha' ,
			'lainnya'=>'Lainnya' 
		);
	 $agama = array(
				'name'=>'agama',
				'value'=>( isset($_POST['agama']) ? $_POST['agama'] : $fields['agama'] ),
				'id'=>'agama', 
			);
	$form_field_marital = form_dropdown($agama , $datasagama);
	$view .= form_field_display( $form_field_marital   , "Agama"    );
	
	$telepon_mobile = array(
				'name'=>'telepon_mobile',
				'value'=>( isset($_POST['telepon_mobile']) ? $_POST['telepon_mobile'] : $fields['telepon_mobile'] ),
				'id'=>'telepon_mobile',
				'type'=>'text','size'=>'45'
			);
	$form_field_telepon_mobile = form_dynamic($telepon_mobile);
	$view .= form_field_display( $form_field_telepon_mobile , "Telepon seluler"    );
	
	
	$asal_daerah = array(
				'name'=>'asal_daerah',
				'value'=>( isset($_POST['asal_daerah']) ? $_POST['asal_daerah'] : $fields['asal_daerah'] ),
				'id'=>'asal_daerah',
				'type'=>'text','size'=>'45'
			);
	$form_field_asal_daerah = form_dynamic($asal_daerah);
	$view .= form_field_display( $form_field_asal_daerah , "Asal daerah"    );
	
	$berat_badan = array(
				'name'=>'berat_badan',
				'value'=>( isset($_POST['berat_badan']) ? $_POST['berat_badan'] : $fields['berat_badan'] ),
				'id'=>'berat_badan',
				'type'=>'text','size'=>'5'
			);
	$form_field_berat_badan = form_dynamic($berat_badan);
	$view .= form_field_display( $form_field_berat_badan , "Berat badan"    );
	
	$tinggi_badan = array(
				'name'=>'tinggi_badan',
				'value'=>( isset($_POST['tinggi_badan']) ? $_POST['tinggi_badan'] : $fields['tinggi_badan'] ),
				'id'=>'tinggi_badan',
				'type'=>'text','size'=>'5'
			);
	$form_field_tinggi_badan = form_dynamic($tinggi_badan);
	$view .= form_field_display( $form_field_tinggi_badan , "Tinggi badan"    );
	
	 
	$alamat_cilegon = array(
				'name'=>'alamat_cilegon',
				'value'=>(isset($_POST['alamat_cilegon']) ? $_POST['alamat_cilegon'] : $fields['alamat_cilegon'] ),
				'id'=>'alamat_cilegon' ,'cols'=>'40','rows'=>'3'
			);
	$form_field_alamat = form_textarea($alamat_cilegon);
	 
	$view .= form_field_display( $form_field_alamat , "Alamat sekarang"   );
	 
	$alamat_ktp = array(
				'name'=>'alamat_ktp',
				'value'=>(isset($_POST['alamat_ktp']) ? $_POST['alamat_cilegon'] : $fields['alamat_ktp'] ),
				'id'=>'alamat_ktp' ,'cols'=>'40','rows'=>'3'
			);
	$form_field_ktpadd = form_textarea($alamat_ktp);
	 
	$view .= form_field_display( $form_field_ktpadd , "Alamat KTP"   );	
	$kota_ktp = array(
				'name'=>'kota_ktp',
				'value'=>(isset($_POST['kota_ktp']) ? $_POST['kota_ktp'] : $fields['kota_ktp'] ),
				'id'=>'kota_ktp' ,'size'=>'40','type'=>'textfield'
			);
	$form_field_ktkota= form_dynamic($kota_ktp);
	 
	$view .= form_field_display( $form_field_ktkota , "Kota Alamat KTP"   );	
	$submit = array(
		'value' => ( $id ==0 ? ' Simpan ' :'  Update  '),
		'name' => 'simpan', 
		'type'=>'submit','class'=>'main_button'
	);
	$form_submit= form_dynamic($submit);
	$reset = array(
		'value' => 'Reset',
		'name' => '', 
		'type'=>'reset','class'=>'main_button'
	);
	$form_reset= form_dynamic($reset);
	
	$view .= form_field_display( $form_submit .' '.$form_reset , "&nbsp;" ,  "" );
	$view .= form_footer( );
	return $view;
}

function form_calon_create($id =0){
	my_set_file_js(array('components/system/js/calendar/calendarDateInput.js','components/system/jquery/combomulti/jquery.chainedSelects.js')); 
	my_set_code_js(' 
	$(function()
	{ 
		$(\'#devisi_id\').chainSelect(\'#jabatan_id\',\'combobox_jabatan.php\',
		{ 
			before:function (target) 
			{ 
				$("#jabatanloading").css("display","block");
				$("#defaultjabatan").css("display","none");
				$(target).css("display","none");
			},
			after:function (target) 
			{ 
				$("#jabatanloading").css("display","none");
				$("#defaultjabatan").css("display","none");
				$(target).css("display","inline");
			}
		});
	});

	' );
	my_set_code_css('
	#jabatanloading
		{  
			background:#ff0000;
			color:#fff;
			font-size:14px;
			font-familly:Arial;
			padding:2px; 
			display:none;
			float:left;
		}
	');
	$fields =  loaddata_karyawan($id);  
	$karyawan_disabled = my_get_data_by_id('karyawan_disable','karyawan_id',$id); 
	$biodata = my_get_data_by_id('biodata','biodata_id',$fields['biodata_id']);	 
	$pelamar = my_get_data_by_id('pelamar','pelamar_id',$karyawan_disabled['pelamar_id']);	 
	$view = form_header( "calon pegawai" , "cp"  ); 
 
	$view .= form_field_display( $fields['nomor_kontrak']  , "Nomor agenda"   );
	 
	$view .= form_field_display(  date('d-m-Y' , strtotime($fields['tanggal_kontrak'])) , "Tanggal agenda"   );
	
	 
	$view .= form_field_display( $fields['nama_gelar']   , "Nama lengkap"   );
	 
	$view .= form_field_display( $fields['idcard'], "Nomor Identitas "    );
	$view .= form_field_display( ucfirst($fields['kelamin']), "Kelamin "    ); 
	$view .= form_field_display( ucfirst($fields['agama']).' / '.ucfirst($fields['marital']), "Agama / Status pernikahan "    );
	
	$kota_kelahiran = my_get_data_by_id('kota','kota_id',$biodata['tempat_lahir']);
	$view .= form_field_display( ucfirst($kota_kelahiran['nama_kota']).', '.date('d-m-Y' , strtotime($fields['tanggal_lahir'])), "Tempat, Tanggal lahir "    );
	
	$panggilan = array(
				'name'=>'panggilan',
				'value'=>( isset($_POST['panggilan']) ? $_POST['panggilan'] : $fields['panggilan'] ),
				'id'=>'panggilan',
				'type'=>'text',
				'size'=>'45'
			);
	$form_field_panggilan = form_dynamic($panggilan);
	
	$view .= form_field_display( $form_field_panggilan    , "Panggilan"   );
	  
	$email = array(
				'name'=>'email',
				'value'=>( isset($_POST['email']) ? $_POST['email'] : $fields['email'] ),
				'id'=>'email',
				'type'=>'text','size'=>'35' 
			);
	$form_field_email = form_dynamic($email);
	$view .= form_field_display( $form_field_email   , "Email"    );
	
	 
	
	$telepon_mobile = array(
				'name'=>'telepon_mobile',
				'value'=>( isset($_POST['telepon_mobile']) ? $_POST['telepon_mobile'] : $fields['telepon_mobile'] ),
				'id'=>'telepon_mobile',
				'type'=>'text','size'=>'45'
			);
	$form_field_telepon_mobile = form_dynamic($telepon_mobile);
	$view .= form_field_display( $form_field_telepon_mobile , "Telepon seluler"    );
	
	
	$asal_daerah = array(
				'name'=>'asal_daerah',
				'value'=>( isset($_POST['asal_daerah']) ? $_POST['asal_daerah'] : $fields['asal_daerah'] ),
				'id'=>'asal_daerah',
				'type'=>'text','size'=>'45'
			);
	$form_field_asal_daerah = form_dynamic($asal_daerah);
	$view .= form_field_display( $form_field_asal_daerah , "Asal daerah"    );
  
	$saudara_perusahaan = array(
				'name'=>'saudara_perusahaan',
				'value'=>( isset($_POST['saudara_perusahaan']) ? $_POST['saudara_perusahaan'] : $fields['saudara_perusahaan'] ),
				'id'=>'saudara_perusahaan',
				'type'=>'text',
				'size'=>'45'
			);
	$form_field_saudara_perusahaan = form_dynamic($saudara_perusahaan); 
	$view .= form_field_display( $form_field_saudara_perusahaan   , "Saudara  di perusahaan"   );
	$motivasi = array(
				'name'=>'motivasi',
				'value'=>( isset($_POST['motivasi']) ? $_POST['motivasi'] : $pelamar['motivasi'] ),
				'id'=>'motivasi', 
			);
	$form_field_motivasi = form_textarea($motivasi); 
	$view .= form_field_display( $form_field_motivasi   , "Motivasi"   );
	

	//KEKARYAWANAN
	
	
	$npwp = array(
				'name'=>'npwp',
				'value'=>( isset($_POST['npwp']) ? $_POST['npwp'] : $fields['npwp'] ),
				'id'=>'npwp',
				'type'=>'text',
				'size'=>'35' 
			);
	$form_field_npwp = form_dynamic($npwp);
	$view .= form_field_display( $form_field_npwp   , "N P W P "    );
	
	$jamsostek = array(
				'name'=>'jamsostek',
				'value'=>( isset($_POST['jamsostek']) ? $_POST['jamsostek'] : $fields['jamsostek'] ),
				'id'=>'jamsostek',
				'type'=>'text',
				'size'=>'35' 
			);
	$form_field_jamsostek = form_dynamic($jamsostek);
	$view .= form_field_display( $form_field_jamsostek   , "Jamsostek"    );
	 
	
	
	
	$submit = array(
		'value' => ( $id ==0 ? ' Simpan ' :'  Update  '),
		'name' => 'simpan', 
		'type'=>'submit','class'=>'main_button'
	);
	$form_submit= form_dynamic($submit);
	$reset = array(
		'value' => 'Reset',
		'name' => '', 
		'type'=>'reset','class'=>'main_button'
	);
	$form_reset= form_dynamic($reset);
	
	$view .= form_field_display( $form_submit .' '.$form_reset , "&nbsp;" ,  "" );
	$view .= form_footer( );
	return $view;
}

function alamat_detail($karyawan_id){
	$karyawan = loaddata_karyawan($karyawan_id); 
	$aaaa = detail_header_view( );
 	$aaaa .= detail_rows_view( 'Alamat KTP' , nl2br( $karyawan['alamat'] ) );
	$aaaa .= detail_rows_view( 'Kota KTP' , $karyawan['kota'] ); 
	$aaaa .= detail_rows_view( 'Kodepos KTP' , $karyawan['kodepos'] ); 
	$aaaa .= detail_rows_view( 'Alamat tinggal' , nl2br( $karyawan['alamat_tinggal'] ) );
	$aaaa .= detail_rows_view( 'Kota tinggal' , $karyawan['kota_tinggal'] ); 
	$aaaa .= detail_rows_view( 'Kodepos tinggal' , $karyawan['kodepos_tinggal'] ); 
	$aaaa .= detail_footer_view();
	return $aaaa;
}

function table_riwayat_pelatihan($karyawan_id){
	$header_hobi = array(
		'#'=>array('style'=>'border-bottom:2px solid;width:15px'),  
		'DARI'=>array('style'=>'border-bottom:2px solid;width:100px'),  
		'SAMPAI'=>array('style'=>'border-bottom:2px solid;width:100px'),     
		'BIDANG'=>array('style'=>'border-bottom:2px solid;width:400px'),     
		'PENYELENGGARA'=>array('style'=>'border-bottom:2px solid;width:400px'),     
		' '=>array('style'=>'border-bottom:2px solid;width:50px'),   
	);
	
	$query = "SELECT * FROM riwayat_pelatihan a 
		INNER JOIN riwayat_pelatihan_karyawan b ON
		a.riwayat_pelatihan_id=b.riwayat_pelatihan_id 
		WHERE b.karyawan_id={$karyawan_id}";
	$result = my_query($query);
	 
	$n =0;
	while(  $ey = my_fetch_array($result)  ){ 
	$n++;
		$editproperty = array(
						'href'=>'index.php?com=riwayat_pelatihan&task=edit_popup&id='.$ey['riwayat_pelatihan_id'], 
						'title'=>'Edit',
						'rel'=>'facebox'
				);
		$edit_button = button_icon( 'b_edit.png' , $editproperty  );
		$edit_button = admin_link($edit_button); 
		$rowsthobi[] = array(
			'#'=> $n,  
			'tahun_dari'=> $ey['tahun_dari'],  
			'tahun_sampai'=> $ey['tahun_sampai']      ,	 
			'bidang'=> $ey['bidang']      ,	 
			'penyelenggara'=> $ey['penyelenggara']      ,	 
			'edit'=>position_text_align( $edit_button,'right')  			
		); 
		
	}
	if($n  < 5){
		for($ycc=$n ; $ycc<=4; $ycc++){
		 
			$rowsthobi[] = array(
				'#'=> '&nbsp;',  
				'kelompok'=> '&nbsp;',  
				'ad'=> '&nbsp;',  
				'hobi'=> '&nbsp;', 	 
				's'=> '&nbsp;', 	 
				'edit'=> '&nbsp;', 	
			); 
		}
	}
	$stshobi = table_rows_plain($rowsthobi); 
	$hobi_table .= table_builder_plain($header_hobi , $stshobi ,  4,false );
	$hobi_table  .= '<div style="text-align:right;width:100%;font:12px verdana;">'.admin_link('<a href="index.php?com=riwayat_pelatihan&task=edit_popup&kid='.$karyawan_id.'&id=0" rel="facebox">[Tambah data]</a>').'</div>'; 
	return $hobi_table;
}


function delete_karyawan($karyawan_id){
	$karyawan_datas =  array(
		'karyawan_id'=>my_type_data_int($karyawan_id), 
	);
	return my_insert_record('karyawan_disable' , $karyawan_datas );
	
/*	
	if( is_calon($karyawan_id) ){
		$querys = "DELETE FROM karyawan_disable WHERE karyawan_id = {$karyawan_id}";
		my_query($querys);
	}
	
	$query = "DELETE FROM karyawan WHERE karyawan_id = {$karyawan_id}";
	return my_query($query);
*/	
}

function form_submit_calon_create($id =0){
	list($dd,$mm,$yyyy) = explode("-" , $_POST['tanggal_lahir']);
	$tanggal = $yyyy .'-'. $mm . '-' . $dd ;
	$datas = array(
		'idcard'=>my_type_data_str($_POST['tno'].'#'.strtoupper($_POST['idcard'])),
		'nama'=>my_type_data_str($_POST['nama']),
		'gelar'=>my_type_data_str($_POST['gelar']),
		'panggilan'=>my_type_data_str($_POST['panggilan']), 
		'kelamin'=>my_type_data_str($_POST['kelamin']), 
		'tempat_lahir'=>my_type_data_int($_POST['tempat_lahir']),
		'tanggal_lahir'=>my_type_data_str($tanggal),
		'marital'=>my_type_data_str($_POST['marital']),
		'agama'=>my_type_data_str($_POST['agama']),
		'email'=>my_type_data_str($_POST['email']), 
		'telepon_mobile'=>my_type_data_str($_POST['telepon_mobile']), 
		'tinggi_badan'=>my_type_data_str($_POST['tinggi_badan']),
		'asal_daerah'=>my_type_data_str($_POST['asal_daerah']),
		'berat_badan'=>my_type_data_str($_POST['berat_badan']),
		'nama_ibu'=>my_type_data_str($_POST['nama_ibu']),
		'alamat_cilegon'=>my_type_data_str($_POST['alamat_cilegon']),
		//'saudara_cilegon'=>my_type_data_str(  $_POST['saudara_cilegon']),
		'saudara_perusahaan'=>my_type_data_str(  $_POST['saudara_perusahaan']),
		'datetime_added'=>my_type_data_function('NOW()')
	); 
	if($id == 0){ 
		$biodata_id = my_insert_record('biodata' , $datas );
		move_uploaded_photo( $_FILES['photo']  , $biodata_id );
		
		$karyawan_datas =  array(
			'biodata_id'=>my_type_data_int($biodata_id), 
			'catatan'=>my_type_data_str($_POST['catatan']),
		);
		$karyawan_id = my_insert_record('karyawan' , $karyawan_datas );

	
		list($dd,$mm,$yyyy) = explode("-" ,$_POST['tanggal_agenda']);
		$calon = array(
				'karyawan_id'=>my_type_data_int($karyawan_id),
				'nomor_agenda'=>my_type_data_str($_POST['nomor_agenda']),
				'tanggal_agenda'=>my_type_data_str(  $yyyy.'-'.$mm.'-'.$dd ),
				'motivasi'=>my_type_data_str(  $_POST['motivasi']),
				'gaji'=>my_type_data_str(  $_POST['gaji']),
				'fasilitas'=>my_type_data_str(  $_POST['fasilitas']),
			);
		my_insert_record('karyawan_disable' , $calon);	
		 
//			my_direct('index.php?com=karyawan&task=detail&id='.$karyawan_id);
		 
	}else{
		$karyawan = my_get_data_by_id('karyawan','karyawan_id',$id);
		 
		my_update_record('biodata','biodata_id',$karyawan['biodata_id'],$datas);
		list($dd,$mm,$yyyy) = explode("-" ,$_POST['tanggal_agenda']);
		$calon = array( 
				'nomor_agenda'=>my_type_data_str($_POST['nomor_agenda']),
				'tanggal_agenda'=>my_type_data_str(  $yyyy.'-'.$mm.'-'.$dd ),
				'motivasi'=>my_type_data_str(  $_POST['motivasi']),
				'gaji'=>my_type_data_str(  $_POST['gaji']),
				'fasilitas'=>my_type_data_str(  $_POST['fasilitas']),
			);
		my_update_record('karyawan_disable' ,'karyawan_id',$id, $calon);
		
		
		$karyawan_datas =  array(
			'biodata_id'=>my_type_data_int( $karyawan['biodata_id'] ), 
			'catatan'=>my_type_data_str($_POST['catatan'])
		);
		
		my_update_record('karyawan' , 'karyawan_id' , $id , $karyawan_datas );
		/*
		if( isset($_GET['status'] ) )
			my_direct('index.php?com=karyawan&task=detail_entry_karyawan&id='.$id);
		 else 
			my_direct('index.php?com=karyawan&task=detail&id='.$id);
		*/
$karyawan_id =	$id	;
		 
	}
	$adadata=my_get_data_by_id('kekaryawanan','karyawan_id',$karyawan_id);
	if($adadata){
	}else{
		$datas = array(
			'karyawan_id'	=>my_type_data_int($karyawan_id),
		);
		my_insert_record('kekaryawanan' , $datas);
	}
	
	$datas = array(
		'npwp'		=>my_type_data_str($_POST['npwp']),
		'jamsostek'		=>my_type_data_str($_POST['jamsostek']),
		
	);
	
	my_update_record( 'kekaryawanan' , 'karyawan_id' , $karyawan_id , $datas );	
		return true;
	
}



function export_to_excel_biodata(){
	my_component_load('xl_builder' , false);
	$header = array( 
		'Name'=>array('style'=>'border-bottom:2px solid;'),  
		'NIK'=>array('style'=>'border-bottom:2px solid;'),  
		'EMAIL'=>array('style'=>'border-bottom:2px solid;'),  
		'JOIN'=>array('style'=>'border-bottom:2px solid;'),  
		'RESIGN'=>array('style'=>'border-bottom:2px solid;'),  
   
		'SEX'=>array('style'=>'border-bottom:2px solid;'),
		'AGAMA'=>array('style'=>'border-bottom:2px solid;'),
		'TGL LAHIR'=>array('style'=>'border-bottom:2px solid;'),
		'GOL'=>array('style'=>'border-bottom:2px solid;'),
		'JOBCODE'=>array('style'=>'border-bottom:2px solid;'),
		'ALAMAT TINGGAL'=>array('style'=>'border-bottom:2px solid;'),
		'ALAMAT KTP'=>array('style'=>'border-bottom:2px solid;'),
		'HOBI'=>array('style'=>'border-bottom:2px solid;'),
		'GOL DARAH'=>array('style'=>'border-bottom:2px solid;'),
		'TINGGI BADAN'=>array('style'=>'border-bottom:2px solid;'), 
		'BERAT BADAN'=>array('style'=>'border-bottom:2px solid;'), 
		'PENDIDIKAN TERAKHIR'=>array('style'=>'border-bottom:2px solid;'), 
		'KOTA PENDIDIKAN AKHIR'=>array('style'=>'border-bottom:2px solid;'),  
	);
	
	$query = "
		SELECT * FROM karyawan a 
		INNER JOIN biodata b ON a.biodata_id = b.biodata_id
		INNER JOIN kekaryawanan c ON a.karyawan_id = c.karyawan_id 
		GROUP BY a.nik
		ORDER BY a.biodata_id , a.karyawan_id DESC 		
	";
	
	$result = my_query($query);
	$row = array();
	$i = 0;
	$exists = array();
	while($ey =my_fetch_array($result)){
		$i++;  
		$jabatan = loaddata_jabatan($ey['jabatan_id']);
		$alamat_tinggal = get_alamat($ey['karyawan_id'],'KTP');
		$alamat_ktp = get_alamat($ey['karyawan_id'],'tinggal');
		//$posbiaya = my_get_data_by_id('pos_biaya','pos_biaya_id' ,$jabatan['pos_biaya_id']);
		$grade = my_get_data_by_id('grade','grade_id',$ey['grade_id']);
		$gol = my_get_data_by_id('golongan_jabatan','golongan_jabatan_id',$ey['golongan_jabatan_id']);
		$pendidikan = pendidikan_tertinggi($ey['karyawan_id']);
		$bank = my_get_data_by_id('bank','bank_id',$ey['bank_id']);
		$status_id=isset($ey['status_id']) ? $ey['status_id'] : 0; 
		$statuss=my_get_data_by_id('status_kekaryawanan','status_id',$status_id);
	    if(in_array($ey['nik'] ,$exists )){ continue; }
		else { $exists[] = $ey['nik_lm'];} 
		$tmt = get_tgl_resign($ey['karyawan_id']);
		$row[] = array( 
			'nama'=>$ey['nama'],
			'nik'=>'\''.sprintf('%07d' ,$ey['nik']),  
			'email'=>$ey['email'],
			'tmb'=>$ey['tmb'],
			'tmt'=>$tmt,
			 
			'kelamin'=>strtoupper($ey['kelamin']),
			'agama'=>strtoupper($ey['agama']),
			'tgl'=>$ey['tanggal_lahir'],
			'gol'=>$gol['kode_golongan_jabatan'],
			'jobcode'=>'\''.sprintf('%08d' ,$jabatan['nomor_posisi']),
			'alamat'=>  $alamat_tinggal ,
			'alamat_ktp'=> $alamat_ktp ,
			'hobi'=> load_hobi($ey['karyawan_id']) ,
			'golda'=> $ey['gol_da'] ,
			'tinggi_badan'=> $ey['tinggi_badan'] ,
			'berat_badan'=> $ey['berat_badan'] , 
			'pendidikan_terakhir'=> strtoupper($pendidikan['nama_lembaga_pendidikan']) , 
			'tempat'=>  strtoupper($pendidikan['lokasi_pendidikan']) , 

		);
	}

 
	$datas = table_rows_excel($row); 
	return table_builder_excel($header , $datas , 15 ,false ); 
}

function get_alamat($karyawan_id , $type){
	$query = "SELECT * FROM alamat WHERE karyawan_id = '{$karyawan_id}' AND type='{$type}' ";
	$result = my_query($query);
	if(  my_num_rows($result) > 0){
		$row = my_fetch_array($result); 
		$lokasi = load_detail_kodepos($row['kodepos_id']);
		return $row['alamat'].' '.$lokasi ;
	}
	return false;
} 

function load_detail_kodepos($kode_id){
	$query = "SELECT * FROM kodepos WHERE kodepos_id = {$kode_id} ";
	$result = my_query($query);
	if( $row = my_fetch_array($result) ){
		return $row['kelurahan'].'
			'.$row['kecamatan'].'
			'.$row['kota'].' '.$row['kodepos'];
	}
	return false;
}

function load_hobi($karyawan_id){
	$query = "SELECT * FROM hobi a 
		INNER JOIN hobi_karyawan b ON a.hobi_id = b.hobi_id
		WHERE b.karyawan_id = {$karyawan_id}";
	$result = my_query($query);
	$text='';
	while($row = my_fetch_array($result)){
		$text .= strtolower($row['nama_hobi']).', ';
	}
	return trim( trim($text) ,",");	
}
 
function pendidikan_tertinggi($karyawan_id){
	$query = "SELECT * FROM riwayat_pendidikan a
		INNER JOIN riwayat_pendidikan_karyawan b
		ON a.riwayat_pendidikan_id = b.riwayat_pendidikan_id
		INNER JOIN pendidikan c ON a.pendidikan_id = c.pendidikan_id
		WHERE b.karyawan_id = {$karyawan_id} ORDER BY c.level_pendidikan_id DESC LIMIT 1 ";
	$result = my_query($query);
	return my_fetch_array($result);
}

function get_tgl_resign($karyawan_id){
	$query = "SELECT * FROM pemberhentian WHERE karyawan_id = {$karyawan_id}";
	$result = my_query($query);
	if( my_num_rows($result) > 0 ){
		$row = my_fetch_array($result);
		return $row['tmt'];
	}
	return false;
}